<%@ page language="java" pageEncoding="UTF-8"%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<%
Object obj=request.getSession().getAttribute("role_resource");
if(null==obj){
	response.setStatus(1000);
	return;
}
%>
<script type="text/javascript">
//查询用户信息
		var store = new Ext.data.JsonStore({
			root: "data",//从返回的json对象data中读取数据
			fields: ["id", "name","mobile","phone","email","duty","state","remark",
			"depNo", "depName","orgNo","orgName","roleNo","roleName","loginName"],
  			url:"person!listByDepart.action"//根据部门查询用户信息
    	});
    	//根据部门获取角色信息
		var store2 = new Ext.data.JsonStore({
			root: "data",//从返回的json对象data中读取数据
			fields: ["rid","rname"],
  			url:"role!listByDepID.action"
    	});
		//状态栏选项
		var store3 = new Ext.data.JsonStore({
			fields: ["id","text"],
  			data:[{id:"1",text:"启用"},{id:"0",text:"禁用"}]
    	});
		    	    	
		var p1 = {
			id: "usergrid",
			xtype: "grid",
			stripeRows:true,
			region: "center",
			loadMask : true,//在加载数据时遮罩住元素,替换元素Updater的加载提示器，并且在初始化加载之后销毁
			autoExpandColumn:"remark",//自动填充
			autoExpandMin : 100,//自动填充最小宽度
			store:store,
			headersDisabled: true,
			columns:[
	        	new Ext.grid.RowNumberer({header: "序号", width: 30}),
	        	{header: "人员编号", dataIndex: "id",	menuDisabled: true},
	        	{header: "人员名称", dataIndex: "name",	menuDisabled: true},
	        	{header: "角色名称", dataIndex: "roleName",	menuDisabled: true},
				{header: "部门名称", dataIndex: "depName",	menuDisabled: true},
				{header: "结构名称", dataIndex: "orgName",	menuDisabled: true},
				{header: "备注",dataIndex:"remark",id:"remark",	menuDisabled: true}
			],
			bbar: new Ext.ux.PagingToolbar({
				id:"user_paging",
	        	pageSize:limit,
	        	store:store
    		})
		};
				
		var user_pel = new Ext.Panel({
			id:"master_panel",
			border : false, 
			layout: "border",
			items: [{
					id:"roleTree",
					xtype: "billTreePanel",
					dataUrl: "tree!role.action",
					root: new Ext.tree.AsyncTreeNode({
						id:"root",//跟节点ID
						expanded : true//是否展开
					}),
					listeners: {
						"click": function(node){
							if(node.isLeaf()){
								store.baseParams["depNo"] = node.id;
								store.load({params:{start : 0,limit :limit}});
								store2.load({params:{"role.did":node.id},callback:function (){
									 var defaultData = {
					                    rid: '',
					                    rname: ''
					                };
					                var recId = store2.getCount()+10; 
					                var p = new store2.recordType(defaultData, recId); 
					                store2.insert(0, p); 
								}});//根据部门ID查询角色
							}
						}
					}
				}, p1]
		});	
		
	var CenterPanel=Ext.getCmp("CenterPanel");
	CenterPanel.removeAll();
	CenterPanel.add(user_pel);
	CenterPanel.doLayout();
</script>